Connect Interpreter module to source

Follow the guide Add Module to Apis Hive, but this time select a module of type ApisInterpreter rom the "Module type" dropdown list.

  • After adding the module, select the new module named "Interpreter" or what name you chose from the Solution Explorer.

Basic setup, communication interface

The module supports both serial and TCP/IP interfaces, depending on your server. In the Properties Editor, enter values for:

  1. TCP/IP based server/source:
    • Comm. type receive : Winsock
    • IP address : IP address of your server .
    • IP Port receive: TCP port of your server .
    • IP Protocol: The protocol of your server, TCP or UDP
    • .
  2. Serial communication based server :
    • Comm. type receive : Serial
    • Serial Com port: Com port connected to the server.
    • Serial Baud rate: Baud rate of your server serial setup.
    • Serial Data bits: Data bits of your server serial setup.
    • Serial Flow Control: Handshake of your server serial setup.
    • Serial Parity: Parity of your server serial setup.
    • Serial StopBit: Stop bits of your server serial setup.
  • Further in the Properties Editor:

    • Timer: enter the value for how often this client should poll (send) for new values on the server (in seconds).
  • Press "Apply" when done.

Mode of operation

Read

When the "Mode of operation" property is set to Read the module will attempt to Read a string from the selected communication port.

Depending of the format of the telegram various properties must be set in addition to the communication properties.

Assume a device sends a telegram with following format:

$GPGLL,5300.97914,N,00259.98174,E,26.375698,A*F<CR<LF>

Now follow the guide Add Items to a Module, but this time add items of type "InterpreterItem".

Buffer size:

First of all we need to allocate enough buffer space to the telegram, this telegram seems to contain nearly 50 characters including <CR>LF>

Setting the property Buffer size to 100 should be adequate.

Terminating character:

The telegram seems to be terminated with <LF> 0xA LineFeed , this means that the Terminating character property should be set to LF. If you dont find your terminating character, just type in the ASCII value of the character (decimal)

This property settings should be enough to receive "raw" telegram. The module reads the interface until terminating character is hit or buffer is full then InterpreterItem is updated.

If communication is OK and the server / device is sending the InterpreterItem tag should be updated.

If we want the module to extract / interpret part(s) of the telegram to different item(s):

Interpret:

Enable the Interpret property.

Field separator:

In this case different values seems to be separated by comma ',' , set Field separator property to Comma.

InterpreterItem property

In property window for the "InterpreterItem" set Adress to the field you want to interpret

$GPGLL,5300.97914,N,00259.98174,E,26.375698,A*F<CR<LF>

0123456
$GPGLL5300.97914N00259.98174E26.375698A

In this case 5

 

The InterpreterItem tag should be updated. with the value from field 5 in the telegram

If other fields need to be extracted just add InterpreterItems an set appropriate Address (fIeld)

Write

Follow the guide Add Items to a Module, but this time add items of type "InterpreterSendItem".

In Write mode the value of the "InterpreterSendItem" is sent to a listening server ,when:

  • The value changes, depends on "Update only on change" attribute.
  • Command Item using this "InterpreterSendItem" as a Parent Item is trigged.

Write->Read

Follow the guide Add Items to a Module, but this time add one item of type "InterpreterSendItem" and one item of type "InterpreterItem"

The value of the "InterpreterSendItem" is sent to a listening server, in same way as in Write mode, it is assumed that the server will send a response, the response will end up in the "InterpreterItem" in same way as in Read mode.

This mode is applicable to trig some kind of synchronous response (reading) from a casual server.

TCP-Server

Follow the guide Add Items to a Module, but this time add items of type "InterpreterSendItem".

This mode

If no "InterpreterItem" are defined the "InterpreterSendItem" is sent to a connected client as a stream, no handshake.

If a "InterpreterItem" is defined the "InterpreterItem" acts as a command identifier, when the server receives data matching the value of the "InterpreterItem" it will respond with the value of "InterpreterSendItem". The Address is used as identificatior.

For instance Worker StringFormatter can be used to format the command and response for your needs.

The example below shows server where two commands are defined "print" and "get_status". The Address property decides what response belongs to what command. When the TCP-Server receives "print" from external client it will respond with "Print job finished Id 177". "print" matches the value of "PrintCmd" item which has Address 10 the server responds with the value of SendItem having Address 10.

In this case PuTTy terminal is connected to the server to demonstrate this feature

If there's no connection or data received:

  • Use a third-party terminal application like putty, to check if the server is sending telegrams.
  • For a TCP/IP based server:
    • Check the firewall settings for the receiving port.
    • Check the network connection to the server, (ping)
  • In many cases the device like hand held scanners send data occasionally , then it might be difficult to figure out whether the device is passive or there is configuration / communication problem.